<script lang='ts' setup>
import { onMounted, reactive, ref } from 'vue';
import { useRouter } from 'vue-router';
import request from "@/assets/工具/网络请求"
import { SCHOOL } from '@/assets/工具/枚举';
import TitleBar from '@/components/标题.vue'
import type { BookingFormData  } from '@/types';
import { getLocalStringDate, getLocalStringDateTime } from '@/assets/工具/工具类';
const vblt = ref([] as BookingFormData[])
const router = useRouter()
const id = sessionStorage.getItem('token')
onMounted(  async () =>{
        try{
            const result =  await request.doGet(`/InsertVisitorOrderServlet?id=${id}`);
   vblt.value = result.data
   console.log('成功获取数据',vblt.value);
    }catch (error) {
   console.error('获取数据出错：',error);
   
    } }
)


const viewDetail = (id:number) =>{
    router.push('/viewBookingDetail/'+id)
}


const pageBack = () =>{
    router.push('/bookingVisitSchool')
}
</script>
<template>
    
    <div class="组件根">
        <div class="标题栏">
            <div class="标题栏占位" @click="pageBack">
                <img src="@/assets/图片/通用/白色返回箭头.png" class="返回箭头 块级图片">
            </div>
            预约信息
            <div class="标题栏占位" @click="pageBack">
            <img class="IMG" src="../assets/图片/通用/个人.jpg" alt="">
        </div>
        </div>
        <ul>
           
                <li  v-if="vblt.length" v-for="order of vblt" :key="order.id">
               
                    <div>订单编号:{{ order.id }}</div>
                    <div>进校时间:{{ getLocalStringDate(order.visitDate) }}</div>
                    <div>下单时间:{{ getLocalStringDateTime(order.bookingTime) }}</div>
                <div>游客人数:{{ order.visitorsInfo.length }}</div>
                <div id="查看详情" @click="viewDetail(order.id)">查看详情</div>
               
            </li>
            <div  v-else>
                <van-notice-bar left-icon="volume-o" :scrollable="false">
  <van-swipe @click="$router.push('/immediatelyBooking')"
    vertical
    class="notice-swipe"
    :autoplay="3000"
    :touchable="false"
    :show-indicators="false"
  >
    <van-swipe-item>您还没有订单！</van-swipe-item>
    <van-swipe-item>点击此处立即去预约界面！</van-swipe-item>
    <van-swipe-item>或手动前往！</van-swipe-item>
  </van-swipe>
</van-notice-bar>
                <van-empty description="无订单！" /></div>
        </ul>
      
    </div>
</template>
<style scoped>

.notice-swipe {
    height: 40px;
    line-height: 40px;
  }
.标题栏 div:nth-child(1) img{
    width: 10px;
  
  height: 20px;
    margin: auto;
}
.标题栏占位 .IMG{
    width: 20px;
  
  height: 20px;
    margin: auto;
    padding-right: 20px;
}

.标题栏占位 {
    width: 40px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  
}

.标题栏 {
    display: flex;
    font-size: 17px;
    align-items: center;
    height: 44px;
    justify-content: space-between;
    box-sizing: border-box;
    width: 375px;
    background-color: aliceblue;
  
}
#查看详情{
    width: 75px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    background-color:maroon;
    color: #FFF;
    border-radius: 11px;
    position: absolute;
    right: 15px;
    bottom: 10px;
    font-size: 12px;
}
ul{
    font-size: 14px;
    padding-top: 10px;
    width: 360px;
    margin:auto;
}
li{
    background-color: #f4e8d1;
    line-height: 22px;
    border-radius: 10px;
    margin-bottom: 5px;
    padding: 5px 10px;
    position: relative;
}
.组件根{
    
    height: 100vh;
    padding-bottom: 45px;
}

</style>